﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.Windows.Browser;
using System.Windows.Automation.Provider;
using System.Windows.Automation;
using System.Windows.Automation.Peers;
using GalaSoft.MvvmLight.Messaging;
using Candy.Infrastructure;
using System.Windows.Navigation;
using Candy.ViewModel;
using System.Reflection;


namespace Candy
{
    public partial class Home : UserControl
    {
        LoginWindow _loginWindow = new LoginWindow();
        RegistrationWindow _regWindow = new RegistrationWindow();
        public Frame Frame { get; private set; }
        public HomeViewModel ViewModel
        {
            get
            {
                return this.DataContext as HomeViewModel;
            }
        }

        ConfirmationWindow _confirmationWindow = new ConfirmationWindow();
        public Home()
        {

            InitializeComponent();
            Assembly assembly = Assembly.GetExecutingAssembly();
            String v = assembly.FullName.Split(',')[1];
            String fullversion = v.Split('=')[1];
            string[] vArr = fullversion.Split(".".ToCharArray());
            int minor = int.Parse(vArr[1]);
            if (minor % 2 == 0)
                version.Text = fullversion;
            else
                version.Text = fullversion + " - Beta"; 
            ErrorHandler.Initialize(ErrorInforCtrl);
            ProgressHandler.Initialize(progReporter);
            ConfirmationHandler.Initialize(_confirmationWindow);

            Frame = frame1;
            frame1.CacheSize = 100;
        }


        void _regWindow_Closed(object sender, EventArgs e)
        {
            if (_regWindow.DialogResult == false)
                _loginWindow.Show();
        }
        private void frame1_Navigated(object sender, NavigationEventArgs e)
        {

        }


    }
}
